xen/arm: p2m: Handle preemption when freeing intermediate page tables
authorJulien Grall <jgrall@amazon.com>
Tue, 11 Oct 2022 12:52:27 +0000 (14:52 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 12:52:27 +0000 (14:52 +0200)
commit937fdbad5180440888f1fcee46299103327efa90
treea1e126f22bb32f3111413280100121b6d59a3b76
parent8d9531a3421dad2b0012e09e6f41d5274e162064
xen/arm: p2m: Handle preemption when freeing intermediate page tables

At the moment the P2M page tables will be freed when the domain structure
is freed without any preemption. As the P2M is quite large, iterating
through this may take more time than it is reasonable without intermediate
preemption (to run softirqs and perhaps scheduler).

Split p2m_teardown() in two parts: one preemptible and called when
relinquishing the resources, the other one non-preemptible and called
when freeing the domain structure.

As we are now freeing the P2M pages early, we also need to prevent
further allocation if someone call p2m_set_entry() past p2m_teardown()
(I wasn't able to prove this will never happen). This is done by
the checking domain->is_dying from previous patch in p2m_set_entry().

Similarly, we want to make sure that no-one can accessed the free
pages. Therefore the root is cleared before freeing pages.

This is part of CVE-2022-33746 / XSA-410.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Tested-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
master commit: 3202084566bba0ef0c45caf8c24302f83d92f9c8
master date: 2022-10-11 14:20:56 +0200
xen/arch/arm/domain.c
xen/arch/arm/p2m.c
xen/include/asm-arm/p2m.h